package com.hhkj.study.admin.user.service.extend.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hhkj.study.admin.user.entity.UserWechatCompany;
import com.hhkj.study.admin.user.model.podo.UserWechatCompanyDo;
import com.hhkj.study.admin.user.model.podo.UserWechatCompanyPo;
import com.hhkj.study.admin.user.service.base.UserWechatCompanyService;
import com.hhkj.study.admin.user.service.extend.UserWechatCompanyExtendService;
import com.ruoyi.common.base.biz.service.extend.BaseExtendServiceImpl;
import org.springframework.stereotype.Service;

/**
*
* @author SERVER
* @since 2024-09-06
*/
@Service
public class UserWechatCompanyExtendServiceImpl extends BaseExtendServiceImpl<UserWechatCompany, UserWechatCompanyDo, UserWechatCompanyPo, UserWechatCompanyService> implements UserWechatCompanyExtendService {

    @Override
    public boolean saveNoRepeat(UserWechatCompanyDo userWechatCompanyDo) {
        LambdaQueryWrapper<UserWechatCompany> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserWechatCompany::getUserId, userWechatCompanyDo.getUserId()).eq(UserWechatCompany::getWxOrgId, userWechatCompanyDo.getWxOrgId());
        long count = this.getService().count(queryWrapper);
        if (count <= 0) {
            return this.getService().save(userWechatCompanyDo);
        }
        return true;
    }
}
